package com.FSS.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Observable;

public class AlarmManager extends Observable{
	ArrayList<Alarm> alarms;
	public AlarmManager(){
		alarms = new ArrayList<Alarm>();
	}
	public void addAlarm(Alarm a){
		alarms.add(a);
		setChanged();
		notifyObservers(alarms);
	}
	public boolean removeAlarm(Alarm a){
		setChanged();
		notifyObservers(alarms);
		return alarms.remove(a);
	}
	public ArrayList<Alarm> getAlarms() {
		return alarms;
	}
	public int getSize(){
		return alarms.size();
	}
	public boolean contains(Date date){
		for(Alarm a:alarms){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String time1=sdf.format(a.getDeleteTime());
			String time2=sdf.format(date);
			if(time1.equals(time2))
				return true;
		}
		return false;
	}
}
